﻿using UnityEngine;
using System.Collections;

public class AsteroidField : MonoBehaviour {
	
	public int asteroidNumber = 400;
	public int radius = 2500;			//innen
	public int spawnRadius = 3500; 	//außen
	public GameObject spawnObject;
	private int asteroidCount;
	
	public Transform asteroidPrefab;

	// Use this for initialization
	void Start () {
		 asteroidCount = 0;
		 spawnObject = GameObject.Find("AsteroidSpawn");
		
		for(int i = 0; i < asteroidNumber; i++)
		{
			Instantiate(asteroidPrefab,transform.position +Random.insideUnitSphere *3000 , Random.rotation);
			asteroidCount++;
		}
	
	}
	
	// Update is called once per frame
	void Update () {
		
		if(asteroidCount< asteroidNumber)
		{
//			Debug.Log(transform.position +Random.insideUnitSphere * Random.Range(radius, spawnRadius));
			Instantiate(asteroidPrefab,transform.position +Random.onUnitSphere *3500 , Random.rotation);
			asteroidCount++;
		}
	
	}
	
	public void lowerCount()
	{
		asteroidCount--;
	}
}
